<template>
    <div class="info-card">
      <!-- 标题部分 -->
      <h2 class="card-title">宿舍房间信息</h2>
      
      <!-- 主要信息区域 -->
      <div class="content-wrapper">
        <!-- 左侧信息列 -->
        <div class="left-column">
          <InfoItem label="房间号" :value="roomNumber" />
          <InfoItem label="楼栋号" :value="buildingNumber" />
          <InfoItem label="楼层" :value="floor" />
          <InfoItem label="房间类型" :value="roomType" />
          <InfoItem label="床位数" :value="bedCount" />
          <InfoItem label="已住人数" :value="occupied" />
          <InfoItem label="空余床位" :value="availableBeds" />
        </div>
  
        <!-- 右侧信息列 -->
        <div class="right-column">
          <InfoItem label="班级" :value="className" />
          <InfoItem label="专业" :value="major" />
          <InfoItem label="班主任" :value="teacher" />
          <InfoItem label="联系电话" :value="phone" />
          
          <!-- 设施信息 -->
          <div class="facilities">
            <h3>设施信息</h3>
            <FacilityItem label="空调" :value="facilities.airConditioner" />
            <FacilityItem label="热水器" :value="facilities.waterHeater" />
            <FacilityItem label="独立卫浴" :value="facilities.bathroom" />
          </div>
  
          <!-- 备注信息 -->
          <div class="remarks">
            <h3>备注信息</h3>
            <p>{{ remarks }}</p>
          </div>
        </div>
      </div>
    </div>
  </template>
  
  <script setup>
  import { defineProps } from 'vue';
  
  // 定义props
  const props = defineProps({
    roomNumber: { type: String, default: '' },
    buildingNumber: { type: String, default: '' },
    floor: { type: String, default: '' },
    roomType: { type: String, default: '' },
    bedCount: { type: String, default: '' },
    occupied: { type: String, default: '' },
    availableBeds: { type: String, default: '' },
    className: { type: String, default: '' },
    major: { type: String, default: '' },
    teacher: { type: String, default: '' },
    phone: { type: String, default: '' },
    remarks: { type: String, default: '无' },
    facilities: {
      type: Object,
      default: () => ({
        airConditioner: '有',
        waterHeater: '有',
        bathroom: '无'
      })
    }
  });
  
  // 信息项子组件
  const InfoItem = (props) => (
    <div class="info-item">
      <span class="label">{props.label}：</span>
      <span class="value">{props.value}</span>
    </div>
  );
  
  // 设施信息子组件
  const FacilityItem = (props) => (
    <div class="facility-item">
      <span class="facility-label">{props.label}：</span>
      <span class={`facility-value ${props.value === '有' ? 'has' : 'none'}`}>
        {props.value}
      </span>
    </div>
  );
  </script>
  
  <style scoped>
  .info-card {
    background: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    max-width: 800px;
    margin: 20px auto;
  }
  
  .card-title {
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 12px;
    margin-bottom: 20px;
  }
  
  .content-wrapper {
    display: flex;
    gap: 30px;
  }
  
  .left-column, .right-column {
    flex: 1;
  }
  
  .info-item {
    display: grid;
    grid-template-columns: 100px 1fr;
    margin-bottom: 12px;
    font-size: 14px;
  }
  
  .label {
    color: #666;
    text-align: right;
    padding-right: 12px;
  }
  
  .value {
    color: #333;
    font-weight: 500;
  }
  
  .facilities {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
  }
  
  .facility-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
  }
  
  .facility-label {
    color: #666;
    width: 80px;
  }
  
  .facility-value {
    font-weight: 500;
  }
  
  .facility-value.has {
    color: #67C23A;
  }
  
  .facility-value.none {
    color: #F56C6C;
  }
  
  .remarks {
    margin-top: 20px;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 4px;
  }
  
  .remarks h3 {
    color: #666;
    font-size: 14px;
    margin-bottom: 8px;
  }
  </style>